{include file='public/_meta'}
<title>车间管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 日常业务 <span class="c-gray en">&gt;</span> 车间管理<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form class="Huiform" method="post" action="{:url('admin/cjgl/index')}" target="_self">
	<div class="text-c">
		<input type="text" class="input-text" style="width:250px" placeholder="输入订单关键词进行检索" id="keywords" name="keywords">
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜订单信息</button>
	</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20" style="margin-bottom: 10px;"> 
		<span class="l">

			<a href="javascript:;" onclick="admin_add('新增订单','adddj.html')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 新增订单</a>
			<a href="javascript:;" onclick="admin_edit('编辑订单')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6df;</i> 编辑订单</a>
			<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除订单</a>

			<a href="javascript:;" onclick="admin_showqt('查看前台','showqt.html')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe61f;</i> 查看前台</a>
			<a href="javascript:;" onclick="admin_printcb('打印出殡订单','printcb.html')" class="btn btn-success radius"><i class="Hui-iconfont">&#xe627;</i> 打印出殡订单</a>
			<a href="javascript:;" onclick="admin_tjcj_select()" class="btn btn-warning radius"><i class="Hui-iconfont">&#xe634;</i> 返还前台</a>
			<a href="javascript:;" onclick="admin_tjcw_select()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6dc;</i> 提交财务</a>

		</span>
		<span class="r">共有数据：<strong>{$totalcounts}</strong> 条</span> 
	</div>
	<table id="listTable" class="table table-border table-bordered table-bg table-sort display">
		<thead>
			<tr>
				<th scope="col" colspan="19">订单列表</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="checkAll" id="checkAll" value="" onclick="selectAll(this)"></th>
				<th width="40">ID</th>
				<th width="80">登记部门</th>
				<th>提交状态</th>
				<th width="60">司仪</th>
				<th width="60">存尸</th>
				<th width="60">房间号</th>
				<th width="70">逝者姓名</th>
				<th width="40">性别</th>
				<th width="50">年龄</th>
				<th width="100">出殡日期</th>
				<th width="90">出殡费用</th>
				<th>火化炉</th>
				<th width="40">炉次</th>
				<th>告别厅</th>
				<th>备注</th>
				<th width="100">登记日期</th>
				<th>预订单号</th>
				<th width="120">操作</th>
			</tr>
		</thead>
		<tbody>
			<!--以下显示前台提交的数据-->
			{if $qtlist}
			{foreach $qtlist as $k=>$v}
			<tr class="text-c">
				<td><input type="checkbox" value="{$v.id}" name=""></td>
				<td>{$v.id}</td>
				<td class="td-status"><span class="label {if $v.djbz==0}label-primary{/if}{if $v.djbz==1}label-secondary{/if}{if $v.djbz==2}label-success{/if} radius">{if $v.djbz==0}前台{/if}{if $v.djbz==1}车间{/if}{if $v.djbz==2}尸检所{/if}</span></td>
				<td class="td-status">
					{if $v.qttjcjbz=='提交车间'}<span class="label label-warning radius">{$v.qttjcjbz}</span>{/if}
					{if $v.qttjcjbz=='车间返还'}<span class="label llabel-danger radius">{$v.qttjcjbz}</span>{/if}
					{if $v.qttjcwbz=='提交财务'}<span class="label label-danger radius">{$v.qttjcwbz}</span>{/if}
					{if $v.qttjcwbz=='财务返还'}<span class="label label-warning radius">{$v.qttjcwbz}</span>{/if}
					{if $v.qttjcjbz=='登记' and $v.qttjcwbz=='登记' and $v.qttjbz=='登记' }<span class="label label-success radius">{$v.qttjbz}</span>{/if}
				</td>
				<td>{$v.sy}</td>
				<td class="td-status"><span class="label {if $v.is_cs=='是'}label-success{else}label-default{/if} radius">{$v.is_cs}</span></td>
				<td>{$v.cs_fjid}</td>
				<td>{$v.xm}</td>
				<td>{$v.xb}</td>
				<td>{$v.nl}</td>
				<td>{$v.cbrq|date="Y-m-d",###}</td>
				<td>{$v.cbfy}</td>
				<td>{$v.ydl}</td>
				<td>{$v.ydlc}</td>
				<td>{$v.gbt}</td>
				<td>{$v.bz}</td>
				<td>{$v.djrq}</td>
				<th>{$v.ddh}</th>
				<td class="td-manage text-l">
					<a title="打印订单" href="javascript:;" onclick="admin_print(this,'{$v.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont" style="font-size: 20px;">&#xe652;</i></a>
					<a title="修改订单" href="javascript:;" onclick="admin_edit_dj('修改订单','<?php echo url('admin/cjgl/editdj',['id'=>$v['id']]);?>')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont" style="font-size: 20px;">&#xe6df;</i></a>
				</td>
			</tr>
			{/foreach}
			{/if}
			<!-- 以上显示前台提交的数据-->

			{if $list}
			{foreach $list as $k=>$v}
			<tr class="text-c">
				<td><input type="checkbox" value="{$v.id}" name="id"></td>
				<td>{$v.id}</td>
				<td class="td-status"><span class="label {if $v.djbz==0}label-primary{/if}{if $v.djbz==1}label-secondary{/if}{if $v.djbz==2}label-success{/if} radius">{if $v.djbz==0}前台{/if}{if $v.djbz==1}车间{/if}{if $v.djbz==2}尸检所{/if}</span></td>
				<td class="td-status">
					{if $v.qttjcjbz=='提交车间'}<span class="label label-warning radius">{$v.qttjcjbz}</span>{/if}
					{if $v.qttjcjbz=='车间返还'}<span class="label label-default radius">{$v.qttjcjbz}</span>{/if}
					{if $v.qttjcwbz=='提交财务'}<span class="label label-danger radius">{$v.qttjcwbz}</span>{/if}
					{if $v.qttjcwbz=='财务返还'}<span class="label label-warning radius">{$v.qttjcwbz}</span>{/if}
					{if $v.qttjcjbz=='登记' and $v.qttjcwbz=='登记' and $v.qttjbz=='登记' }<span class="label label-success radius">{$v.qttjbz}</span>{/if}
				</td>
				<td>{$v.sy}</td>
				<td class="td-status"><span class="label {if $v.is_cs=='是'}label-success{else}label-default{/if} radius">{$v.is_cs}</span></td>
				<td></td>
				<td>{$v.xm}</td>
				<td>{$v.xb}</td>
				<td>{$v.nl}</td>
				<td>{$v.cbrq|date="Y-m-d",###}</td>
				<td>{$v.cbfy}</td>
				<td>{$v.ydl}</td>
				<td>{$v.ydlc}</td>
				<td>{$v.gbt}</td>
				<td>{$v.bz}</td>
				<td>{$v.djrq}</td>
				<th>{$v.ddh}</th>
				<td class="td-manage text-l">
					{if $v.qttjcwbz=='提交财务'}
					<a title="查看订单详情" href="javascript:;" onclick="admin_show_dj('查看订单','<?php echo url('admin/cjgl/showdj',['id'=>$v['id'],'show'=>1]);?>')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont" style="font-size: 20px;">&#xe725;</i></a>
					{else}
					<a title="打印订单" href="javascript:;" onclick="admin_print(this,'{$v.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont" style="font-size: 20px;">&#xe652;</i></a>
					<a title="修改订单" href="javascript:;" onclick="admin_edit_dj('修改订单','<?php echo url('admin/cjgl/editdj',['id'=>$v['id']]);?>')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont" style="font-size: 20px;">&#xe6df;</i></a>
					<a title="删除订单" href="javascript:;" onclick="admin_del(this,'{$v.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont" style="font-size: 20px;">&#xe6e2;</i></a>
					{/if}

				</td>
			</tr>
			{/foreach}
			{else}
			<tr class="text-c">
				<td colspan="19">暂无信息</td>
			</tr>
			{/if}
		</tbody>
	</table>
</div>
<div style="display: none;" id="printBox"></div>
<!--_footer 作为公共模版分离出去-->
{include file='public/_footer'}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="__PUBLIC__lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    var t
    $(document).ready(function(){
		t = $('#listTable').dataTable({
			"aaSorting": [[ 1, "asc" ]],//默认第几个排序
			"bStateSave": false,//状态保存
			"aoColumnDefs": [
			//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
			{"orderable":false,"aTargets":[0,3,18]}// 制定列不参与排序
			]
		});
		$('#listTable tbody tr').click(function () {
			if ( $(this).hasClass('selected') ) {
				$(this).removeClass('selected');
			} else {
				$('#listTable tbody tr.selected').removeClass('selected');
				$(this).addClass('selected');
			}
		} );
	});

	function selectAll(obj){
        if (obj.checked) {
            $("input[name='id']").attr("checked", true);
        } else {
            $("input[name='id']").attr("checked", false);
        }
	}

	/*
		参数解释：
		title	标题
		url		请求的url
		id		需要操作的数据id
		w		弹出层宽度（缺省调默认值）
		h		弹出层高度（缺省调默认值）
	*/
	/*订单-增加*/
	function admin_add(title,url,w,h){
		layer_show_max(title,url,w,h);
	}
	/*订单-修改*/
	function admin_edit_dj(title,url,w,h){
		layer_show_max(title,url,w,h);
	}

	/*订单-新增殡品*/
	function admin_showqt(title,url,w,h){
		layer_show_max(title,url,w,h);
	}

    // 打印出殡列表
    function admin_printcb(title,url,w,h){
        layer_show_max(title,url,w,h);
    }

	// 弹出即全屏
	function layer_show_max(title,url){
		if (title == null || title == '') {
			title=false;
		};
		if (url == null || url == '') {
			url="404.html";
		};
		var index = layer.open({
			type: 2,
			//area: ['320px', '195px'],
			maxmin: true,
			shade:0.4,
			title: title,
			content: url
		});
		layer.full(index);
	}

	/*订单-删除*/
	function admin_del(obj,id){
		layer.confirm('确认要删除吗？',function(index){
			$.ajax({
				type: 'POST',
				url: "{:url('admin/cjgl/deletedj')}",
				dataType: 'json',
				data:{'ids':id},
				success: function(data){
					//console.log(data.ydlcid);
					if(parseInt(data.statusCode)==200){
						$(obj).parents("tr").remove();
						layer.msg(data.message,{icon:1,time:1000});
					}else{
						layer.msg(data.message,{icon:2,time:1000});
					}

				},
				error:function(data) {
					console.log(data.message);
				},
			});
		});
	}
	/*订单-批量删除*/
	function datadel(){
		var gid = '';
		layer.confirm('确定要执行该批量操作吗？',function(){
				$("input:checkbox").each(function(index){

					if($(this).is(':checked')==true){
						var id = $(this).val();
						if(id){
							gid += id+','
						}
					}
				});
				gid = gid.substring(0,gid.length-1);
				//console.log(gid);
				if(gid==''){
					layer.msg("请选择要操作的项");
				}else{
                    $.ajax({
                        type: 'POST',
                        url: "{:url('admin/cjgl/deletedj')}",
                        dataType: 'json',
                        data:{'ids':gid},
                        success: function(data){
                            //console.log(data.message);
                            if(parseInt(data.statusCode)==200){
                                //$(obj).parents("tr").remove();
                                layer.msg(data.message,{icon:1,time:1000});
                                window.location.reload();
                            }else{
                                layer.msg(data.message,{icon:2,time:1000});
                            }

                        },
                        error:function(data) {
                            console.log(data.message);
                        },
                    });
				}
		});

	}

	/*订单-提交车间*/
	function admin_tjcj(obj,id){
		layer.confirm('确认要把该订单返还前台吗？',function(index){
			//此处请求后台程序，下方是成功后的前台处理……
			$.getJSON("{:url('admin/cjgl/tjqt')}", { 'ids': id}, function(res){
				alert(res.message);
				window.location.reload();
			});
		});
	}
	/*订单-查看详情*/
	function admin_show_dj(title,url){
        layer_show_max(title,url);
    }
    /*订单-提交财务*/
    function admin_tjcw(obj,id){
        layer.confirm('确认要提交该订单到财务吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            $.getJSON("{:url('admin/cjgl/tjcw')}", { 'ids': id}, function(res){
                layer.msg(res.message,{icon:1,time:1000});
                window.location.reload();
            });
        });
    }

	/*订单-打印*/
	function admin_print(obj,id){
		layer.confirm('确认要打印订单吗？',function(index){
			$.ajax({
				type: 'POST',
				url: "{:url('admin/cjgl/printdj')}",
				dataType: 'json',
				data:{'id':id,'show':0},
				success: function(data){
					//console.log(data.message);
					if(parseInt(data.statusCode)==200){
						//console.log(data);
						//layer.alert(data.data);
						$('#printBox').html(data.data);
						layer.close(index);
						return true;
					}else{
						layer.msg(data.message,{icon:2,time:1000});
						return false;
					}

				},
				error:function(data) {
					console.log(data.message);
				},
			});
		});
	}
	function closeWindow(){
		var index = parent.layer.getFrameIndex(window.name);
		window.parent.location.reload();
	}

	// 选择行添加殡品
	function admin_addbp(title){
        if(_value()){
            admin_add_bp(title,"addbp.html?id="+_value(),1050,750);
        }
    }
    // 选择行修改订单
    function admin_edit(title){
        if(_value()){
            admin_edit_dj(title,"editdj.html?id="+_value());
        }
    }

    // 选择行提交车间
	function admin_tjcj_select(){
        if(_value()){
            admin_tjcj(this,_value());
        }
    }
    // 选择行提交车间
    function admin_tjcw_select(){
        if(_value()){
            admin_tjcw(this,_value());
        }
    }
	// 检测是否选择了一行数据
    function _value() {
        var v = t.fnGetData('.selected');
        if(v==null){
            alert('请选择一行进行操作');
            return false;
        }else{
            return v[1];
        }
    }


</script>
</body>
</html>